import Vue from 'vue';
import App from './App';
// import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import router from './router';
import store from './store';
import API from '@/api';
import * as filters from './common/filters';
import * as directives from './common/directives';

import {
  Button,
  Select,
  Carousel,
  CarouselItem,
  Form,
  Pagination,
  Input,
  InputNumber,
  Collapse,
  FormItem,
  Dialog,
  ButtonGroup,
  CollapseItem,
  Card,
  Message
} from 'element-ui'

// Vue.use(ElementUI);
Vue.use(Button)
Vue.use(Select)
Vue.use(Carousel)
Vue.use(CarouselItem)
Vue.use(Form)
Vue.use(Pagination)
Vue.use(Input)
Vue.use(InputNumber)
Vue.use(Collapse)
Vue.use(Dialog)
Vue.use(ButtonGroup)
Vue.use(CollapseItem)
Vue.use(FormItem)
Vue.use(Card)

Vue.use(require('vue-wechat-title'));

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key]);
});

Vue.prototype.$API = API;
Vue.config.productionTip = false;

router.afterEach(() => {
  window.scrollTo(0, 0);
});

new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {
    App
  },
  mounted() {
    // 从session中恢复用户信息
    this.$store.commit('restore_user_info');
  }
});
